package org.hongbo.springbootebsapi.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hongbo.springbootebsapi.annotations.ResponseResult;
import org.hongbo.springbootebsapi.entity.payment.PaymentEntity;
import org.hongbo.springbootebsapi.service.login.ICurrentUser;
import org.hongbo.springbootebsapi.service.payment.IPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@ResponseResult
@Controller
@RestController
@Slf4j
public class PaymentController {

    @Autowired
    private IPaymentService paymentService;

    @Autowired
    private ICurrentUser currentUser;

    @GetMapping("/getAllPayment")
    public List<PaymentEntity> getAllPayment(){
       return paymentService.queryPayment(currentUser.getCurrentUser());
    }

    @ApiOperation(value="切换职责", notes="切换职责刷新token")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paymentId", value = "付款单号", required = true, dataType = "String")
    })
    @GetMapping("/findPayment")
    public PaymentEntity findPayment(String paymentId){
        log.info(" paymentId = "+paymentId);
        return paymentService.findPayment(paymentId,currentUser.getCurrentUser());
    }

}
